<?php
/**
 * Created by PhpStrom
 * User: 魏惠东
 * Date: 2021/6/2 15:09
 * Desc:
 */

namespace App\Models\Admin;
use App\Models\BaseModel;

class PostGroup extends BaseModel{
    protected $table = "post_group";
    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s'
    ];

    protected $fillable=["name","sort","site_id","creator"];
    /**
     * 列表
     * @param $search 条件数组
     */
    public static function getList($limit,$search){
        return self::
        where(function($query) use ($search){
            if(!empty($search['keyword'])){
                $query->where("name","like","%".$search['keyword']."%");
            }
        })->orderBy('sort','asc')->orderBy('id','desc')->paginate($limit)->toArray();
    }
    public static function findData($id){
        return self::where("id",$id)->first();
    }

}
